module.exports = function(grunt) {
  //配置项
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    //打包RequireJS文件（注意，AngularJS App由RequireJS加载）
    requirejs: {
      compile: {
        options: {
          baseUrl: './public',
          name: "ngApp/ng-main",
          optimize: "uglify",
          mainConfigFile: "public/build.conf.js",
          out: "public/ngApp/ng-main.min.js"
        }
      }
    },
    //合并CSS文件
    concat: {
      css: {
        src: [
          'public/packages/bower/bootstrap/dist/css/bootstrap.css',
          'public/ngApp/*/css/*.css',
          'public/packages/bower/angular-toasty/css/ng-toasty.css',
          'public/packages/bower/bootstrap-markdown/css/bootstrap-markdown.min.css',
          'public/packages/bower/font-awesome/css/font-awesome.css'
        ],
        dest: 'public/css/concat.tmp.css'
      }
    },
    //压缩CSS文件
    cssmin: {
      css:{
        src: 'public/css/concat.tmp.css',
        dest: 'public/css/min.css'
      }
    },
    //移动第三方字体文件到公开目录的根目录下
    shell: {
      makeFontsDir:{
        command: "if [ ! public/fonts ]; then \n mkdir public/fonts \n fi"
      },
      copyBootstrapFonts: {
        command: 'cp public/packages/bower/bootstrap/fonts/* public/fonts/'
      },
      copyAwesomeFonts: {
        command: 'cp public/packages/bower/font-awesome/fonts/* public/fonts'
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-css');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-shell');

  grunt.registerTask('default',['requirejs', 'concat', 'cssmin', 'shell']);


};